import { Mqtt } from './mqtt';

// const mqttList = new Array<Mqtt>() as Array<Mqtt>

const host = 'ws://10.134.232.13:8083/mqtt';
const option = {
  username: 'YTXX_emqx',
  password: 's<KF+V6H<|/lDO*q+N)Q',
  clean: true,//离线时是否接收 QoS 1 和 2 的消息 false 为接收,true为不接收
  reconnectPeriod: 5000 //重连时间间隔
};

const mq = new Mqtt(host)
mq.connect(option)

// 订阅主题 可一次订阅多个主题
// mq.subscribe(['frontend/#', 'topology/#'], 0)
// 设置主题 /topicName/data 的消息回调
// mq.message_callback('testtopic/top1', dealMessage.bind(this))
// 设置主题 /topicName/rx 的消息回调
// mq.message_callback('testtopic5/topic2', dealMessage.bind(this))

export default mq